package com.briup.cms.dao;

import com.briup.cms.bean.Article;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper

public interface ArticleMapper {
    @Results({
            @Result(column="publish_date",property = "publishDate"),
            @Result(column="read_times",property = "readTimes"),
            @Result(column="thumb_up_times",property="thumbUpTimes"),
            @Result(column="thumb_down_times",property = "thumbDownTimes"),
            @Result(column="category_id",property="categoryId"),
            @Result(column="user_id",property = "userId")

    })
    @Select("select * from article")
    List<Article> selectAll();
    @Insert("insert into article values(null,#{title},#{content},#{publishDate},#{readTimes},#{thumbUpTimes},#{thumbDownTimes},#{status},#{categoryId},#{userId})")
    void insert(Article article);
    @Update("update article set title=#{title},content=#{content},publish_date=#{publishDate},read_times=#{readTimes},thumb_up_times=#{thumbUpTimes},thumb_down_times=#{thumbDownTimes},status=#{status},category_id=#{categoryId},user_id=#{userId} where id=#{id}")
    void update(Article article);
    @Delete("delete from article where id=#{id}")
    void deleteById(Long id);
}
